package network;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.SocketException;
import java.util.HashMap;

public class UdpDictServer  extends UdpEchoServer{
    private HashMap<String,String> hash = new HashMap<>();

    public UdpDictServer(int port) throws SocketException {
        super(port);
        hash.put("cat","小猫");
        hash.put("dog","小狗");
        hash.put("shazi","刘");
    }

    @Override
    public String process(String request) {
        return hash.getOrDefault(request,"输入有误");
    }

    public static void main(String[] args) throws IOException {
        UdpEchoServer server = new UdpDictServer(9090);
        server.start();
    }
}
